package com.mdc.mansion.api.web.modules.pay;

import com.alibaba.fastjson.JSONObject;
import com.mdc.mansion.api.web.common.web.BaseController;
import com.mdc.mansion.common.response.Result;
import com.mdc.mansion.common.response.ResultCode;
import com.mdc.mansion.core.modules.pay.RestaurantPayCfgService;
import com.mdc.mansion.core.modules.pay.dto.RestaurantPayCfgDto;
import com.mdc.mansion.core.modules.restaurant.dto.RestaurantDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;


@Controller
@RequestMapping(value = "${adminPath}/payCfg")
public class RestaurantPayCfgController extends BaseController {

	@Resource
	private RestaurantPayCfgService restaurantPayCfgService;
	
	/**
	 * 保存和更新
	 * @param data
	 * @return
	 */
	@RequestMapping(value="/save")
	private Result saveCfg(String data)
	{
		Result result = new Result(ResultCode.COMMON_SUCCESS);
		RestaurantPayCfgDto dto= JSONObject.parseObject(data,RestaurantPayCfgDto.class);
		restaurantPayCfgService.savePayInfo(dto);
		return result;
	}
	
	/**
	 * 查询
	 * @param data
	 * @return
	 */
	@RequestMapping(value="/get")
	public Result getPayCfgInfo(String data){
		Result result = new Result(ResultCode.COMMON_SUCCESS);
		RestaurantPayCfgDto dto = restaurantPayCfgService.getPayCfgInfo();
		result.setProperty("payInfo",dto);
		return result;
	}
	
	/**
	 * 删除
	 * @param data
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public Result delete(String data) {
		Result result = new Result(ResultCode.COMMON_SUCCESS);
		
		return result;
	}

}
